change the background of an element in a loop using css

45

    var colors = ['blue', 'green', 'yellow', 'black'],
        colorIndex = 0,
        $body = $('body');
    
    setInterval(function(){ $body.css('background', colors[colorIndex++ % colors.length])}, 1000);

Comments

Submit
0 Comments